const { getDataset } = require('../../../../../utils/util')
Component({
    data: {
        activeIndex: 0,
        navigation: [
            {name: '我的',active: true},
            {name: '关心',active: false}
        ],
        activeIndex: 0
    },
    methods: {
        tapNavi(e) {
            const index = getDataset(e, 'index')
            if (index === undefined || index === this.data.activeIndex) return

            const navigation = this.data.navigation
            navigation.forEach((item, i) => {
                item.active = i === index
            })
            this.setData({
                activeIndex: index,
                navigation
            })
            this.triggerEvent('change', index === 0 ? 'mine' : 'care')
        }
    }
})